import axios from 'axios'
import store from '@/store'

const request = axios.create({
  baseURL: 'http://127.0.0.1:7001' // 基础路径
})
request.interceptors.request.use(
  function(config) {
    const { user } = store.state

    if (user.token) {
      config.headers.Authorization = `Bearer ${store.state.user.token}`
    }

    return config
  },
  function(err) {
    // 处理响应的错误信息
    return Promise.all(err)
  }
)
export default request
